'use strict';

angular.module('myApp.teach_leave_old', [])

.controller('teach_leave_oldCtrl', ['$scope','$http',
    function($scope,$http) {

    $http.get('v1/teacher/'+ kget('id')+'/ask_for_leave').success(function(data){
		var temp_result = data.result['data'];
		console.log(temp_result);
		var temp_result_length = temp_result.length;
		for( var i=0; i<temp_result_length ; i++ ){
			switch (temp_result[i].condition ){
				case 0:
					temp_result[i].condition = '申请中';
					break;
				case 1:
					temp_result[i].condition = '已批准';
					break;
				case 2:
					temp_result[i].condition = '未通过';
					break;
				default:
					temp_result[i].condition = '已结束';
			}
		}	
		$scope.leaves = temp_result;


    	console.log($scope.leaves);
    });
}]);